<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm" th:object="${gun}">
                        <input type="hidden" th:value="${gun.id}" name="id"/>
                        <input name="orgId"  type="hidden" th:value="${gun.orgId}" id="treeId"/>
                        <input name="stakeCode"  type="hidden" th:value="${gun.stakeCode}" id="stakeCode"/>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><span class="mustInput">*</span>充电枪编号：</label>
                            <div class="col-sm-8">
                                <select id="gunNum" name="gunNum" class="selectpicker show-tick form-control" title="请选择" th:with="type=${@dict.getType('gun_code')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{gunNum}"></option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">状态：</label>
                            <div class="col-sm-8">
                                <select id="status" name="status" class="form-control m-b" th:with="type=${@dict.getType('gun_status')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{status}"></option>
                                </select>
                            </div>
                        </div>
                        <!-- 附加信息结束 -->
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <div class="btn btn-primary" onclick="save()">提交</div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script>
    function save() {
        // 必输校验
        var hasFlag = 0;
        $('#signupForm input').each(function (index, item) {
            var val = $.trim($(item).val());
            var dataNull = $(item).data('null');
            if (!val && !hasFlag && dataNull) {
                hasFlag = 1;
                layer.msg(dataNull);
            }
        })
        if (hasFlag) {
            return;
        }
        $.ajax({
            cache: true,
            type: "POST",
            url:  ctx+"cdzGun/editSave",
            data: $('#signupForm').serialize(), // 你的formid
            async: false,
            error: function (request) {
                parent.layer.alert("网络超时");
            },
            success: function (data) {
                if (data.code == 0) {
                    parent.layer.msg("操作成功");
                    parent.location.reload();
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                } else {
                    parent.layer.alert(data.msg)
                }

            }
        });
    }
</script>
</body>
</html>